home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 012 / case.arc / CASE.ASM next >
Encoding:
Assembly Source File  |  1985-12-21  |  7.8 KB  |  182 lines

  1.  
  2. COMMENT^ *** CASE.COM *** Last Rev. 10/08/83 *** Vincent T. Bly ***
  3.  -------------------------------------------------------------------
  4. |                                                                   |
  5. | PURPOSE:  Provide a resident utility to aid assembly language     |
  6. |           programmers who wish to write their source code in      |
  7. |           ALL CAPS and their comments in lower case.              |
  8. |                                                                   |
  9. | FUNCTION: Change the cursor shape to indicate the present state   |
  10. |           of the "Caps Lock" key (block cursor for caps lock and  |
  11. |           underline cursor for upper/lower case).                 |
  12. |           Shift to upper/lower case for comments whenever the ";" |
  13. |           key is pressed.                                         |
  14. |           Shift to caps lock for source code whenever the "Enter" |
  15. |           key is pressed.                                         |
  16. |           Toggle the ";"/"Enter" case switching off or on when-   |
  17. |           ever both shift keys are pressed simultaneously.        |
  18. |                                    |
  19. | TO USE:   From DOS, type CASE and press the "Enter" key.        |
  20. |                                                                   |
  21. | NOTES:    This version works with either the color graphics or    |
  22. |        monochrome card.  The DOS utilities (DIR, DEBUG, etc.)  | 
  23. |           do not turn off the cursor during printing.  If you     |
  24. |           find the effect with the block cursor objectionable,    |
  25. |           you can temporarily turn off the case switching by      |
  26. |           pressing both shift keys simultaneously or you can      |
  27. |        change the DWs defining the cursor shapes.            |      
  28. |                                                                   |
  29.  -------------------------------------------------------------------^
  30.  
  31. INTERRUPTS    SEGMENT    AT 00H    ;*********** Interrupt vector table **
  32.         ORG    09H*4
  33. KB_INT        LABEL    DWORD        ; keyboard hardware interrupt
  34.          ORG    16H*4
  35. KEYBRD_INT    LABEL    DWORD        ; keyboard software interrupt
  36. INTERRUPTS    ENDS
  37.  
  38. BIOS_DATA    SEGMENT    AT 40H    ;*********** BIOS data segment *******
  39.         ORG    10H
  40. EQUIP_FLAG    LABEL    WORD        ; bits 4 & 5 indicate CRT board type
  41.         ORG    17H
  42. KYBD_FLAG    LABEL    BYTE        ; primary keyboard status flag
  43.         ORG    63H
  44. ADDR_6845    LABEL    WORD        ; port address of 6845 index register
  45. BIOS_DATA    ENDS
  46.  
  47. CSEG        SEGMENT    
  48.         ORG    100H        ; necessary for a .COM file
  49.         ASSUME    CS:CSEG
  50. START:        JMP    INITIALIZE    ; jump to initilization routine
  51. CAP_CURSOR_C    DW    0006H        ; caps lock cursor type (color board)
  52. CAP_CURSOR_M    DW    000BH        ;     as above, for monochrome board
  53. LOW_CURSOR_C    DW    0607H        ; upper/lower case cursor type (color)
  54. LOW_CURSOR_M    DW    0B0CH        ;     as above, for monochrome board
  55. ROM_KEY_INT    DD            ; ROM keyb'rd hardware interrupt addr.
  56. ROM_KYBD_IO    DD            ; ROM keyb'rd software interrupt addr.
  57. CASE_FLAG    DB    0FFH        ; case switching flag (FF=on, 00=off)
  58. OLD_KYF        DB    040H        ; old value of KYBD_FLAG
  59.  
  60.  
  61. ;===========================================================================;
  62. @HARD_KYBD_INT    PROC    FAR            ; Keyboard hardware interrupts  ;
  63.         ASSUME CS:CSEG,DS:BIOS_DATA ; (09H) are re-vectored to here ;
  64.         STI                ;-------------------------------;
  65.         PUSHF            ; set-up to call like an interrupt
  66.         CALL    ROM_KEY_INT    ; call ROM BIOS, but return here
  67.         PUSH    AX        ; save regs
  68.         PUSH    DS
  69.         MOV    AX,BIOS_DATA    ; point DS to BIOS data seg
  70.         MOV    DS,AX
  71.         MOV    AL,[KYBD_FLAG]    ; get BIOS keyboard status flag
  72.         CMP    AL,CS:[OLD_KYF]    ; has status flag changed?
  73.         JE    GO_BACK        ; if not, go back
  74.         MOV    CS:[OLD_KYF],AL    ; refresh old status flag value
  75.         CALL    SET_CURSOR    ; go set proper cursor type
  76.         AND    AL,3        ; mask all but shift keys
  77.         CMP    AL,3        ; check for both shift keys down
  78.         JNE    GO_BACK        ; if not both shifts, skip toggle
  79.         MOV    AL,CS:[CASE_FLAG] ; get case switch flag
  80.         NOT    AL        ; toggle flag
  81.         MOV    CS:[CASE_FLAG],AL ; replace flag
  82. GO_BACK:    POP    DS
  83.         POP    AX
  84.         IRET            ; back to program
  85. @HARD_KYBD_INT    ENDP
  86.  
  87. ;============================================================================;
  88. SET_CURSOR    PROC    NEAR    ; Set cursor for uppr/lowr case or caps lock ;
  89.         ASSUME    CS:CSEG,DS:BIOS_DATA ;-------------------------------;
  90.         PUSH    AX        ; save regs
  91.         PUSH    BX
  92.         PUSH    DX
  93.         LEA    BX,LOW_CURSOR_C    ; load upper/lower case cursor
  94.         TEST    AL,40H        ; is caps lock on?
  95.         JZ    CHK_BOARD    ; if not, go check board type
  96.         LEA    BX,CAP_CURSOR_C    ; load caps lock cursor
  97. CHK_BOARD:    MOV    AX,EQUIP_FLAG    ; get equipment flag
  98.         AND    AX,30H        ; isolate CRT board type bits
  99.         CMP    AX,30H        ; is it monochrome board?
  100.         JNE    CG_SET        ; if not, skip ahead
  101.         ADD    BX,2        ; bump BX to mono cursor type
  102. CG_SET:        MOV    BX,CS:[BX]    ; get proper cursor into BX 
  103.         MOV    DX,ADDR_6845    ; point to 6845 index reg
  104.         MOV    AL,10D        ; point to cursor start reg
  105.         OUT    DX,AL        ; select cursor start reg 
  106.         INC    DX        ;     point to 6845 data reg
  107.         MOV    AL,BH        ;     data into AL
  108.         OUT    DX,AL        ;     data to cursor start reg
  109.         DEC    DX        ; point to 6845 index reg
  110.         MOV    AL,11D        ; point to cursor end reg
  111.         OUT    DX,AL        ; select cursor end reg
  112.         INC    DX        ;     point to 6845 data reg
  113.         MOV    AL,BL        ;     next data into AL
  114.         OUT    DX,AL        ;     data to cursor end reg
  115.         POP    DX        ; restore regs
  116.         POP    BX
  117.          POP    AX
  118.         RET
  119. SET_CURSOR    ENDP
  120.  
  121.  
  122. ;============================================================================;
  123. @SOFT_KYBD_INT    PROC    FAR             ; Keyboard software interrupts  ;
  124.         ASSUME    CS:CSEG,DS:BIOS_DATA ; (16H) are re-vectored to here ;
  125.         STI                 ;-------------------------------;
  126.         OR    AH,AH        ; is it wait for keyboard input?
  127.         JZ    THIS_ROUTINE    ; if so, do this routine
  128.         JMP    ROM_KYBD_IO    ; else go to ROM & back to caller
  129. THIS_ROUTINE:    PUSHF            ; set-up to CALL like an interrupt
  130.         CALL    ROM_KYBD_IO    ; call ROM BIOS, but return here
  131.         PUSH    AX        ; save caller's registers
  132.         PUSH    DS        ;     "
  133.         TEST    CS:[CASE_FLAG],1 ; is case switching flag on?
  134.         JZ    BACK_TO_CALLER    ; if case flag off, skip the rest
  135.         CMP    AL,";"        ; is the character a semicolon?
  136.         JE    CAPS_OFF    ; if so, go turn caps lock off
  137.         CMP    AL,0DH        ; is the character a carriage return?
  138.         JE    CAPS_ON        ; if so, go turn caps lock on
  139. BACK_TO_CALLER:    POP    DS        ; restore caller's registers
  140.         POP    AX        ;     "
  141.         IRET            ; return to the caller
  142. ;--- Toggle caps lock for ";" or "Enter" ----------------------------------
  143. CAPS_ON:    STC            ; set carry to indicate caps on
  144. CAPS_OFF:    MOV    AX,BIOS_DATA    ; point to BIOS data segment
  145.         MOV    DS,AX
  146.         MOV    AL,[KYBD_FLAG]    ; get keyboard state flag
  147.         JC    SET_ON        ; if caps should be set on, skip ahead
  148.         AND    AL,NOT 40H    ; turn off caps lock
  149.         JMP    REPLACE_FLAG
  150. SET_ON:        OR    AL,40H        ; turn caps lock on
  151. REPLACE_FLAG:    MOV    [KYBD_FLAG],AL    ; replace keyboard state flag
  152.         CALL    SET_CURSOR    ; go set proper cursor type
  153.         JMP    BACK_TO_CALLER
  154. @SOFT_KYBD_INT    ENDP
  155.  
  156. ;============================================================================;
  157. INITIALIZE    PROC    NEAR              ; Re-vector keyb'rd interrupts ;
  158.         ASSUME    CS:CSEG,DS:INTERRUPTS ;------------------------------;
  159.         MOV    AX,INTERRUPTS    ; point to interrupt vector segment
  160.         MOV    DS,AX
  161. ;--- Set intercept for software keyboard interrupt -------------------------
  162.         MOV    AX,KEYBRD_INT    ; save old keyboard interrupt vector
  163.         MOV    ROM_KYBD_IO,AX
  164.         MOV    AX,KEYBRD_INT[2]
  165.         MOV    ROM_KYBD_IO[2],AX
  166.         MOV    AX,OFFSET @SOFT_KYBD_INT ; reset keyboard interrupt
  167.         MOV    KEYBRD_INT,AX    ; vector to point to this routine
  168.         MOV    KEYBRD_INT[2],CS
  169. ;--- Set intercept for hardware keyboard interrupt -------------------------
  170.         MOV    AX,KB_INT    ; save old keyboard interrupt vector
  171.         MOV    ROM_KEY_INT,AX
  172.         MOV    AX,KB_INT[2]
  173.         MOV    ROM_KEY_INT[2],AX
  174.         MOV    AX,OFFSET @HARD_KYBD_INT ; reset keyboard interrupt
  175.         MOV    KB_INT,AX    ; vector to point to this routine
  176.         MOV    KB_INT[2],CS
  177.         MOV    DX,OFFSET INITIALIZE ; point to end of resident code
  178.         INT    27H        ; terminate but stay resident
  179. INITIALIZE    ENDP
  180.  
  181. CSEG        ENDS
  182.         END    START